package vng.wcc.sonph.Demo;

import vng.wcc.sonph.LauncherGenerator.CellInfo;
import vng.wcc.sonph.LauncherGenerator.Formatter;
import vng.wcc.sonph.LauncherGenerator.LauncherGenerator;
import vng.wcc.sonph.LauncherGenerator.R;
import android.content.Intent;
import android.os.Bundle;

/**
 * To use the LauncherGenerator we have to extend it (example: vng.wcc.sonph.Demo.LauncherDemo 
 * please follow the instruction:
 * - Use a subclass to extend LauncherGenerator
 * - The subclass has to set up the items list
 * - Then
 * @author Hung Son
 *
 */
public class LauncherDemo extends LauncherGenerator {

	static final int NUM_COLS_PER_PAGE = 3;
	/** Called when the activity is first created. */
	Intent[] intent;
	CellInfo[][] items;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setDemoData();
		
		this.createLauncherView(items, NUM_COLS_PER_PAGE);
		
		//This is optional, the root view is just a ViewFlipper
		//this.getRootView().setBackgroundResource(R.drawable.background);
		setContentView(this.getRootView());
	}
	/** 
	 * 
	 */
	private void setDemoData() {
		//Create intent to launch by clicking on the icon
		intent = new Intent[2];
		intent[0] = new Intent(this,ShowOddMessage.class);
		intent[1] = new Intent(this,ShowEvenMessage.class);

		//Create the items to add into the view
		items = new CellInfo[3][];
		
		//Provide the layout for the LauncherView
		Formatter cellFormatter = new Formatter(this, NUM_COLS_PER_PAGE);
		
		items[0] = new CellInfo[6];
		items[0][0] = new CellInfo(this,R.drawable.home,cellFormatter, "Trang chu Zing", intent[0]);
		items[0][1] = new CellInfo(this,R.drawable.blog,cellFormatter, "Zing me", intent[0]);
		items[0][2] = new CellInfo(this,R.drawable.chat,cellFormatter,"Zing Chat", intent[1]);
		items[0][3] = new CellInfo(this,R.drawable.news,cellFormatter,"Zing News", intent[0]);
		items[0][4] = new CellInfo(this,R.drawable.mail,cellFormatter,"Zing Mail!", intent[1]);		
		items[0][5] = new CellInfo(this,R.drawable.mp3player,cellFormatter, "Zing Mp3", intent[1]);
		
		items[1] = new CellInfo[3];
		items[1][0] = new CellInfo(this,R.drawable.money, cellFormatter,"Chuyen doi tien", intent[0]);
		items[1][1] = new CellInfo(this,R.drawable.shopping, cellFormatter,"123 Mua", intent[1]);
		items[1][2] = new CellInfo(this,R.drawable.cinema, cellFormatter,"Lich chieu phim", intent[0]);
		
		items[2] = new CellInfo[6];
		items[2][0] = new CellInfo(this,R.drawable.animals, cellFormatter,"Nong trai vui ve", intent[0]);
		items[2][1] = new CellInfo(this,R.drawable.castle, cellFormatter,"Lau dai ma", intent[0]);
		items[2][2] = new CellInfo(this,R.drawable.chess, cellFormatter,"Co vua", intent[0]);
		items[2][3] = new CellInfo(this,R.drawable.deathrace, cellFormatter,"Death race", intent[0]);
		items[2][4] = new CellInfo(this,R.drawable.dice, cellFormatter,"Xoc dia", intent[0]);
		items[2][5] = new CellInfo(this,R.drawable.king, cellFormatter,"Lam sep !", intent[0]);
	}

}
